# Maintainer: Mateusz Mikuła <mati865@gmail.com>
# Contributor: Renato Silva <br.renatosilva@gmail.com>

pkgname=ccache
pkgver=4.2
pkgrel=1
pkgdesc="A compiler cache (mingw-w64)"
arch=('i686' 'x86_64')
url="https://ccache.samba.org/"
license=("GPL3")
replaces=("${pkgname}-git")
makedepends=("gcc"
             "cmake"
             "pkg-config"
             "zlib-devel"
             "libzstd-devel")
depends=("gcc-libs" "zlib" "libzstd")
options=('staticlibs' 'strip')
install="${pkgname}.install"
source=(https://github.com/ccache/ccache/releases/download/v${pkgver}/ccache-${pkgver}.tar.xz{,.asc})
validpgpkeys=("5A939A71A46792CF57866A51996DDA075594ADB8") #Joel Rosdahl <joel@rosdahl.net>
sha256sums=('2f14b11888c39778c93814fc6843fc25ad60ff6ba4eeee3dff29a1bad67ba94f'
            'SKIP')

build() {
  [[ -d build-${CHOST} ]] && rm -rf build-${CHOST}
  mkdir -p build-${CHOST}  && cd build-${CHOST}

  /usr/bin/cmake \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=Release \
    ../${pkgname}-${pkgver}

  make
}

package() {
  cd "${srcdir}/build-${CHOST}"
  make DESTDIR="${pkgdir}" install

  install -Dm644 ${srcdir}/${pkgname}-${pkgver}/GPL-3.0.txt ${pkgdir}/usr/share/licenses/${pkgname}/GPL-3.0.txt
  install -Dm644 ${srcdir}/${pkgname}-${pkgver}/LGPL-3.0.txt ${pkgdir}/usr/share/licenses/${pkgname}/LGPL-3.0.txt
}
